From: Owen W. Taylor Date: Mon, 5 May 2014 22:58:01 +0000 (-0400) Subject: trivial-httpd: flush after writing the port to stdout X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~1202 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=466671407de87cc366b4cb5c590d108a5516e30d;p=ostree.git trivial-httpd: flush after writing the port to stdout The option --port-file=- is most useful when the stdout of the daemon is programatically redirected and not going to a terminal. The flush-after-a-line behavior of stdout is specific to terminals, so we need an explicit flush. https://bugzilla.gnome.org/show_bug.cgi?id=729609 --- diff --git a/src/ostree/ot-builtin-trivial-httpd.c b/src/ostree/ot-builtin-trivial-httpd.c index 0689a3cb..4cfc4b47 100644 --- a/src/ostree/ot-builtin-trivial-httpd.c +++ b/src/ostree/ot-builtin-trivial-httpd.c @@ -353,7 +353,10 @@ ostree_builtin_trivial_httpd (int argc, char **argv, OstreeRepo *repo, GCancella { gs_free char *portstr = g_strdup_printf ("%u\n", soup_server_get_port (server)); if (g_strcmp0 ("-", opt_port_file) == 0) - fputs (portstr, stdout); // not g_print - this must go to stdout, not a handler + { + fputs (portstr, stdout); // not g_print - this must go to stdout, not a handler + fflush (stdout); + } else if (!g_file_set_contents (opt_port_file, portstr, strlen (portstr), error)) goto out; }